<!-- 首页 -->
<template>
	<view class="container">
		<view class="c-swipe">
			<u-swipe-action>
				<u-swipe-action-item :options="options" :name="index" @click="onOrgRecruitItem" v-for="(item,index) in resumeList" :key="item.id">
					<view class="swipe-item" >
						<view class="">
							<text style="font-size: 32rpx;font-weight: bold;line-height: 50rpx;">{{item.title }}</text>
						</view>
						<view class="">
							<text style="color: #aaa;">{{item.desc}}</text>
						</view>
					</view>
				</u-swipe-action-item>
			</u-swipe-action>

		</view>
		<view class="rich-btn">
			<view @click="toOrgRecruitAdd">
				<text>发布新职位</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "",
		data() {
			return {
				resumeList: [],
				options: [{
					text: '编辑',
					style: {
						backgroundColor: '#3c9cff'
					}
				}, {
					text: '删除',
					style: {
						backgroundColor: '#f56c6c'
					}
				}]
			}
		},
		onShow() {
			this.getSelfOrgRecruit()
		},
		methods: {
			onOrgRecruitItem(obj){
				if(obj.index == 0){ // 编辑
					this.navigateTo('orgRecruitAdd?id='+this.resumeList[obj.name].id)
				}else{
					this.$http.delOrgRecruit({id:this.resumeList[obj.name].id}).then(res=>{
						uni.$u.toast("已删除")
						this.getSelfOrgRecruit()
					})
				}
			},
			toOrgRecruitAdd() {
				this.navigateTo('orgRecruitAdd')
			},
			// 获取已发布的职位列表
			getSelfOrgRecruit() {
				this.$http.getSelfOrgRecruit().then(res => {
					this.resumeList = res.data
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.container {
		.c-swipe {
			padding-bottom: 120rpx;

			.swipe-item {
				width: 100%;
				padding: 10rpx 20rpx;
				box-sizing: border-box;
				background-color: #fff;
			}
		}

		.rich-btn {
			width: 100%;
			height: 100rpx;
			padding: 20rpx 0;
			position: fixed;
			bottom: 0;
			left: 0;
			background-color: #fff;

			&>view {
				// width: 160rpx;
				// height: 60rpx;
				width: 100%;
				font-size: 38rpx;
				font-weight: bold;
				color: #4093ec;
				display: flex;
				justify-content: center;
				align-items: center;
			}
		}
	}
</style>
